package com.example.makerspace.controller.productBulletins;


import com.example.makerspace.dto.PageRequest;
import com.example.makerspace.dto.ProductBulletinsDTO;
import com.example.makerspace.dto.Result;
import com.example.makerspace.service.ApplicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@ResponseBody
@RequestMapping("/api/productBulletins")
@Api(tags = "产品公告模块")
public class ProductBulletinsController {

    @Resource
    private ApplicationService applicationService;

    @ApiOperation(value="后台-增加产品公告接口",notes ="后台-增加产品公告接口说明")
    @PostMapping("/addBulletins")
    public Result addBulletins(@ModelAttribute ProductBulletinsDTO bulletinsDTO){
        return  applicationService.addBulletins(bulletinsDTO);
    }
    @ApiOperation(value="后台-修改公告接口",notes ="后台-修改公告接口说明")
    @PostMapping("/updateBulletins")
    public Result updateBulletins(@ModelAttribute ProductBulletinsDTO bulletinsDTO){
        return  applicationService.updateBulletins(bulletinsDTO);
    }

    @ApiOperation(value="后台-删除产品公告接口",notes ="后台-删除产品公告接口说明")
    @GetMapping("/deleteBulletins")
    public Result deleteBulletins(@RequestParam("id") Integer id){
        return  applicationService.deleteBulletins(id);
    }

    @ApiOperation(value="后台-查询所有公告列表接口",notes ="后台-查询所有公告列表接口说明")
    @PostMapping("/selectAllProductsBulletins")
    public Result selectAllProductsBulletins(@RequestBody PageRequest pageRequest){
        return  applicationService.selectAllProductsBulletins(pageRequest);
    }

    @ApiOperation(value="前台-查询所有公告列表接口",notes ="前台-查询所有公告列表接口说明")
    @GetMapping("/selectProductsBulletins")
    public Result selectProductsBulletins(){
        return  applicationService.selectProductsBulletins();
    }
}
